---
sidebar_position: 42 # Use alphabetical order
---

# runOnUISync

`runOnUISync` lets you run a [workletized](/docs/fundamentals/glossary#to-workletize) function synchronously on the [UI Runtime](/docs/fundamentals/runtimeKinds#ui-runtime).

## Reference

```javascript
import { runOnUISync } from 'react-native-worklets';

const myFunction = (num: number): number => {
  'worklet';
  return num + 1;
};

const result: number = runOnUISync(myFunction, 0);

console.log(result); // 1
```

<details>
<summary>Type definitions</summary>

```typescript
function runOnUISync<Args extends unknown[], ReturnValue>(
  worklet: (...args: Args) => ReturnValue,
  ...args: Args
): ReturnValue;
```

</details>

### Arguments

#### worklet

A function you want to execute on the [UI Runtime](/docs/fundamentals/runtimeKinds#ui-runtime).

#### args

Arguments to pass to the function.

### Returns

`runOnUISync` returns the return value of the function passed as the first argument. It can only return values that can be converted to a [Serializable](/docs/memory/serializable).

## Remarks

- The callback passed as the argument is automatically [workletized](/docs/fundamentals/glossary#to-workletize) and ready to be run on the [UI Runtime](/docs/fundamentals/runtimeKinds#ui-runtime).

- Make sure not to execute `runOnUISync` on the [UI Runtime](/docs/fundamentals/runtimeKinds#ui-runtime) or a [Worker Runtime](/docs/fundamentals/runtimeKinds#worker-runtime) as this will result in an error.
